package com.open.party.cloud.view.examine.fragment

import cn.android.x.model.data.AppPageData
import cn.android.x.model.data.PageReq
import cn.android.x.model.data.ResultInfo
import com.open.party.cloud.model.CommVo
import com.open.party.cloud.model.ExamineBean
import com.open.party.cloud.view.examine.ExamineDoingActivity
import com.sinothk.android.utils.XUtils
import com.sinothk.rxretrofit.bean.PageVo


class ExamineUndoneListFragment : ExamineBaseListFragment() {

    override fun loadData(pageVo: PageVo<CommVo>) {
        val pageReq = PageReq<CommVo>()
        pageReq.pageNo = pageVo.pageNum
        pageReq.pageSize = pageVo.pageSize

        val vo = CommVo()
        vo.isTest = false
        pageReq.data = vo

        viewModel!!.getExamineListData(pageReq, "Undone")
    }

    override fun showData(result: ResultInfo<AppPageData<ExamineBean>>) {
        if ("Undone" != result.eventType) {
            return
        }
        updateAdapter(result)
    }

    override fun onClick(position: Int, itemData: ExamineBean, flag: String?) {
        if (itemData.state == 2) {
            XUtils.intent().openActivity(activity, ExamineDoingActivity::class.java)
                .putStringExtra("examinationId", itemData.examinationId)
                .startInFragment(this)
        } else {
            XUtils.toast().show("当前不是考试时间")
        }
    }
}